package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.AppFunction;
import org.apache.ibatis.annotations.*;

public interface AppFunctionMapper {
    @Delete({
        "delete from app_function",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into app_function (id, app_type, ",
        "fun_name, fun_uri, ",
        "enable, create_time, ",
        "update_time)",
        "values (#{id,jdbcType=BIGINT}, #{appType,jdbcType=TINYINT}, ",
        "#{funName,jdbcType=VARCHAR}, #{funUri,jdbcType=VARCHAR}, ",
        "#{enable,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updateTime,jdbcType=TIMESTAMP})"
    })
    int insert(AppFunction record);

    int insertSelective(AppFunction record);

    @Select({
        "select",
        "id, app_type, fun_name, fun_uri, enable, create_time, update_time",
        "from app_function",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    AppFunction selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(AppFunction record);

    @Update({
        "update app_function",
        "set app_type = #{appType,jdbcType=TINYINT},",
          "fun_name = #{funName,jdbcType=VARCHAR},",
          "fun_uri = #{funUri,jdbcType=VARCHAR},",
          "enable = #{enable,jdbcType=BIT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(AppFunction record);

    //************

    @Select({
            "select",
            "id, app_type, fun_name, fun_uri, enable, create_time, update_time",
            "from app_function",
            "where app_type = #{appType,jdbcType=TINYINT} and fun_uri = #{funUri,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    AppFunction selectByUri(@Param("appType") Integer appType, @Param("funUri") String funUri);

}